﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Steamrunner
{
    class Button : DrawableGameComponent
    {
        SpriteBatch spritebatch = null;

        Texture2D button = null;
        Texture2D hoverButton = null;

        Vector2 position = Vector2.Zero;
        string filename;
        string changeToScreen;

        int state = (int)Enums.ButtonState.NORMAL;

        public int State
        {
            get { return state; }
            set { state = value; }
        }

        public string ChangeToScreen
        {
            get { return changeToScreen; }
        }

        public Button(Game game, SpriteBatch spriteBatch, string filename, Vector2 position, string screen)
            : base(game)
        {
            spritebatch = spriteBatch;
            this.filename = filename;
            this.position = position;
            changeToScreen = screen;
        }

        protected override void LoadContent()
        {
            button = Game.Content.Load<Texture2D>(filename);
            hoverButton = Game.Content.Load<Texture2D>(filename + "_over");
        }

        public override void Draw(GameTime gameTime)
        {
            switch (state)
            {
                case (int)Enums.ButtonState.NORMAL :
                    spritebatch.Draw(button, position, Color.White);
                    break;
                case (int)Enums.ButtonState.HOVER :
                    spritebatch.Draw(hoverButton, position, Color.White);
                    break;
            }

            base.Draw(gameTime);
        }
    }
}
